package com.woniuxy.platform.app.apiImpl;

import com.woniuxy.cloud.mall95.log.Log;
import com.woniuxy.platform.client.RoleClient;
import com.woniuxy.platform.service.RoleResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import result.Result;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/platform")
public class RoleClientImpl implements RoleClient {

    @Resource
    private RoleResourceService roleResourceService;

    @Log("给角色添加权限")
    @Override
    public Result addRoleResource(Integer roleId, Integer resourcesId) throws IOException {
        roleResourceService.addRoleResource(roleId,resourcesId);
        return Result.success();
    }

    @Override
    public Result delRoleResource(Integer roleResourceId) {
        roleResourceService.delRoleResource(roleResourceId);
        return Result.success();
    }

    @Override
    public Result<List<String>> checkRoleResource(Integer roleId) {
        List<String> list = roleResourceService.checkRoleResource(roleId);
        return Result.success(list);
    }
}
